class GetDataContinues{
    constructor(){
        this.id_btnGetValue = "#btnContinuesGetValue";
        this.id_imgGetValue = "#imgContinuesGetValue";
        this.id_xpathGetValue = "#xpathContinuesGetValue";
        this.id_hours = "#hours";
        this.id_minutes = "#minutes";
        this.id_seconds = "#seconds";

        this.m_normal_obj = {
            tabId: chrome.devtools.inspectedWindow.tabId,
            msg_type: MSG_NORMAL,
        }

        this.model = new Object();
        this.init_model();

        this.warning_bar = new WarningConfirmBar();
    }

    init_model(){
        this.model.value_xpath = '';
        this.model.hours = 0;
        this.model.minutes = 0;
        this.model.seconds = 0;
    }

    refresh(){
        // 刷新页面
        $(this.id_xpathGetValue).val(this.model.value_xpath);
        $(this.id_hours).val(this.model.hours);
        $(this.id_minutes).val(this.model.minutes);
        $(this.id_seconds).val(this.model.seconds);
    }

    register_GetDataContinues(){
        let mc_this = this;

        this.warning_bar.register_warning();

        $(this.id_btnGetValue).click(function(){
            // 改变元素表现

            // 发送消息
            let msg = mc_this.m_normal_obj;
            msg.todo = "getDataContinues";
            msg.todo_type = GlobalValue.XPATH_TYPE_CONTINUES_GET_DATA;

            web_info_object.send_msg_to_background(msg);
        });

        $(this.id_xpathGetValue).click(function(){

        });

        $(this.id_hours).change(function(){
            if (isNaN($(this).val())){
                console.log("Input value error");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不是数字");
                return false;
            }else if(Number($(this).val()) > 24){
                console.log("Value is overflow");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不能超过24");
                return false;
            }else{
                mc_this.model.hours = $(this).val();
            }
        });

        $(this.id_minutes).change(function(){
            if (isNaN($(this).val())){
                console.log("Input value error");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不是数字");
                return false;
            }else if(Number($(this).val()) > 60){
                console.log("Value is overflow");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不能超过60");
                return false;
            }else{
                mc_this.model.minutes = $(this).val();
            }
        });

        $(this.id_seconds).change(function(){
            if (isNaN($(this).val())){
                console.log("Input value error");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不是数字");
                return false;
            }else if(Number($(this).val()) > 60){
                console.log("Value is overflow");
                $(this).val(0);
                mc_this.warning_bar.display_warning("不能超过60");
                return false;
            }else{
                mc_this.model.seconds = $(this).val();
            }
        })
    }

    active_GetDataContinues(){

    }

}